home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 49
/
Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso
/
-serious-
/
graphics
/
amicad
/
arexx
/
chargerc.amicad
< prev
next >
Wrap
Text File
|
1999-12-06
|
4KB
|
158 lines
/* Tracé de la courbe de charge d'un condensateur.
$VER: 1.00 (© R.Florac, 12 Novembre 1998) */
options results /* indispensable pour récupérer le résultat des macros */
signal on error /* pour l'interception des erreurs */
signal on syntax
clip=-1
FIRSTSEL; obj=result
if obj>0 then do
'TYPE(FIRSTSEL)'; type=result
if type=22 then do
'CLIPUNIT(5)'; clip=result
'COORDS(FIRSTSEL)'; coords=result
PARSE VAR coords x0 ',' y0 ',' x1 ',' y1
xg=minima(x0,x1); xd=maxima(x0,x1)
yh=minima(y0,y1); yb=maxima(y0,y1)
l=xd-xg+1; h=yb-yh+1
'NEXTSEL('obj')'; obj=result
end
end
else obj=1
if obj>0 then do
'MESSAGE("Dessinez et sélectionnez"+CHR(10)+"un rectangle dans"+CHR(10)+"lequel doit être"+CHR(10)+"intégrée la grille")'
call quitter
end
ndh=5
y1=yh+h
x1=xg+ndh*(l%ndh)
'SAVEALL(-1)'
'DELETE(FIRSTSEL):ROTATE(0,0)'
/* Tracé des lignes verticales */
do i=1 to 5
x2 = xg+i*(l/ndh)
x2 = x2%1
'DRAWMODE(1)'
do c=1 to 9
xc = x2-(l/ndh)/10*c
xc=xc%1
'DRAW('xc','yh','xc','yb')'
end
'DRAWMODE(2):DRAW('x2','yh','x2','yb')'
end
/* Repères verticaux */
if h>300 then hc=2
else hc=1
if l>600 then lc=2
else lc=1
'SETSCALE(0,'lc'*100,'hc'*100)'
if lc=1 then lc=8
else lc=16
if hc=1 then hc=8
else hc=16
if xg-5*lc<0 then do
'MESSAGE("Position grille incorrecte"+CHR(10)+"(Trop à gauche)")'
call quitter
end
'DRAWMODE(1):WRITE("0",'xg-lc-lc','yb+hc/2')'
p=h%4
'WRITE("0,25",'xg-4*lc-lc','yh+3*p+hc/2')'
'WRITE("0,5",'xg-3*lc-lc','yh+2*p+hc/2')'
'WRITE("0,75",'xg-4*lc-lc','yh+p+hc/2')'
'WRITE("1",'xg-lc-lc','yh+hc/2')'
/* Tracé des lignes horizontales */
ndv=2
do i=1 to ndv
y2 = yh+(i-1)*(h/ndv)
y2=y2%1
'DRAWMODE(2):DRAW('xg','y2','xd','y2')'
y2 = (yh)+i*(h/ndv)
y2 = y2%1
'DRAWMODE(1)'
do c=1 to 9
yc = y2-(h/ndv)/10*c
yc=yc%1
'DRAW('xg','yc','xd','yc')'
end
end
/* Repères horizontaux */
n=0.5
p=(l/10)%1
ndv=yb+hc+hc/2
'WRITE("0",'xg-lc/2','ndv')'
'WRITE("0,5",'xg+p-lc','ndv')'
'WRITE("1RC",'xg+2*p-2*lc+lc/2','ndv')'
'WRITE("1,5",'xg+3*p-2*lc+lc/2','ndv')'
'WRITE("2RC",'xg+4*p-2*lc+lc/2','ndv')'
'WRITE("2,5",'xg+5*p-2*lc+lc/2','ndv')'
'WRITE("3RC",'xg+6*p-2*lc+lc/2','ndv')'
'WRITE("3,5",'xg+7*p-2*lc+lc/2','ndv')'
'WRITE("4RC",'xg+8*p-2*lc+lc/2','ndv')'
'WRITE("4,5",'xg+9*p-2*lc+lc/2','ndv')'
'WRITE("5RC",'xg+10*p-2*lc+lc/2','ndv')'
/* Tracé des axes */
'WRITE("U",'xg-lc*2','yh-hc')'
'WRITE("t",'xd+3*lc','ndv')'
'DRAWMODE(2):DRAW('xg','yb','xg','yh-hc'):DRAW('xg','yb','xd+2*lc','yb')'
'SETSCALE(0,100,100):CONVERT(PUTPART("Flèche",'xg-10','yh-hc-20'),1)'
'ROTATE(0,1):CONVERT(PUTPART("Flèche",'xd+2*lc','yb-10'),1):DRAWMODE(3)'
/* Tracé de la courbe de charge */
if ~show('L','rexxmathlib.library') then
call addlib('rexxmathlib.library',0,-30)
tau=l/5
y0=yb; x0=xg
do i=1 to l/5
y=h+(-h*exp(-5*i/tau))
y=y%1
'DRAW('x0','y0','x0+5','yb-y')'
x0=x0+5
y0=yb-y
end
/* Tracé de la courbe de charge */
y0=yh; x0=xg
do i=1 to l/5
y=h+(-h*exp(-5*i/tau))
y=y%1
'DRAW('x0','y0','x0+5','yh+y')'
x0=x0+5
y0=yh+y
end
call quitter
minima: procedure
parse arg v1,v2
if v1<v2 then return v1
return v2
end
maxima: procedure
parse arg v1,v2
if v1>v2 then return v1
return v2
end
quitter: procedure expose clip
if clip>=0 then 'CLIPUNIT('clip')'
exit
/* Traitement des erreurs, interruption du programme */
syntax:
erreur=RC
'MESSAGE("Erreur de syntaxe"+CHR(10)+"en ligne 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
exit
error:
'MESSAGE("Erreur en ligne 'SIGL'")'
exit